package com.chen.dao;

import com.chen.pojo.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.Date;
import java.util.List;

public class UserMapperImpl2 extends SqlSessionDaoSupport implements UserMapper{

    //继承SqlSessionDaoSupport可以直接获得SqlSession对象
    public List<User> getUsers() {

        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);

        User user = new User("小山", "33333", new Date());
        mapper.addUser(user);
        mapper.deleteUser(8);
        return mapper.getUsers();

    }

    public int addUser(User user){
        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }

    public int deleteUser(int id){
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }

}
